<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <button>定位</button>
</body>
</html>

<script>
  let btn = document.querySelector('button');
  btn.onclick = () => {
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(r){
      if(this.getStatus() == BMAP_STATUS_SUCCESS){
        var mk = new BMap.Marker(r.point);
        var myGeo = new BMap.Geocoder();
        myGeo.getLocation(new BMap.Point(r.point.lng,r.point.lat), function(rs){
          // console.log(MyApp.app.mapCenter);
          console.log(rs);
          var addComp = rs.addressComponents;
          alert(addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber);
        });
      }
      else {
        alert('未知地址（'+this.getStatus() + '）');
      }
    });
  }
</script>
